//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.come.mouslisten;

import com.tool.role.RoleData;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.List;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.UpgradeJpanel;
import org.come.Jpanel.WashJpanel;
import org.come.entity.Goodstable;
import org.come.entity.PartJade;
import org.come.until.AccessSuitMsgUntil;
import org.come.until.MessagrFlagUntil;

public class RoleSuitMouslisten implements MouseListener {
    private int index;
    private WashJpanel washJpanel;
    private UpgradeJpanel upgradeJpanel;
    private int page;

    public RoleSuitMouslisten(int index, WashJpanel washJpanel, UpgradeJpanel upgradeJpanel) {
        this.index = index;
        this.washJpanel = washJpanel;
        this.upgradeJpanel = upgradeJpanel;
        this.page = this.page;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        if (e.getButton() == 3) {
            List<Goodstable> listrolesuit = AccessSuitMsgUntil.accessIdlEqu(2);
            if (listrolesuit == null) {
                return;
            }

            if (this.index + WashJpanel.page * 21 + 1 > listrolesuit.size()) {
                return;
            }

            Goodstable goodstable = null;
            if (listrolesuit.get(this.index + WashJpanel.page * 21) != null) {
                goodstable = (Goodstable)listrolesuit.get(this.index + WashJpanel.page * 21);
            }

            if (goodstable == null) {
                return;
            }

            if (goodstable.getGoodlock() == 1) {
                ZhuFrame.getZhuJpanel().addPrompt("套装 " + goodstable.getGoodsname() + " 处于加锁状态");
                return;
            }

            int index;
            if (this.washJpanel != null) {
                WashJpanel.getLabSet().setIcon(new ImageIcon((new ImageIcon("img/item/" + goodstable.getSkin() + ".png")).getImage().getScaledInstance(50, 50, 10)));
                WashJpanel.getGoodstableBean().setGoodstable(goodstable);

                for(int i = 0; i < 4; ++i) {
                    WashJpanel.getLabsx()[i].setText("");
                }

                List<String> attr = AccessSuitMsgUntil.getSuitAttr(AccessSuitMsgUntil.getExtra(goodstable.getValue(), "套装属性"));
                if (attr == null) {
                    return;
                }

                index = attr.size() >= 4 ? 4 : attr.size();

                for(int i = 0; i < index; ++i) {
                    WashJpanel.getLabsx()[i].setText((String)attr.get(i));
                }
            }

            if (this.upgradeJpanel != null) {
                UpgradeJpanel.setGoodstable((Goodstable)null);
                UpgradeJpanel.getLabtz2().setIcon((Icon)null);
                UpgradeJpanel.getLabtz1().setIcon(new ImageIcon((new ImageIcon("img/item/" + goodstable.getSkin() + ".png")).getImage().getScaledInstance(50, 50, 10)));
                String suitname = goodstable.getGoodsname().split("\\·")[0];
                boolean partid = true;
                index = Integer.parseInt(goodstable.getValue().split("\\|")[1].split("=")[1]);
                if (index != -1) {
                    PartJade jade = RoleData.getRoleData().getPackRecord().getPartJade(AccessSuitMsgUntil.returnSuitID(suitname), index);
                    if (!jade.isJade()) {
                        int pz = AccessSuitMsgUntil.returnJadeType(AccessSuitMsgUntil.returnnewEx(0, AccessSuitMsgUntil.getExtra(goodstable.getValue(), "套装属性")));
                        if (pz < 5 && jade.getJade(pz + 1) > 0) {
                            UpgradeJpanel.getGoodstableBean().setPartJade(jade);
                            UpgradeJpanel.getGoodstableBean().setType(pz + 1);
                            UpgradeJpanel.getLabyf().setIcon(new ImageIcon((new ImageIcon("img/item/tzyf" + (pz + 1) + ".png")).getImage().getScaledInstance(50, 50, 10)));
                        }
                    }
                }

                UpgradeJpanel.getGoodstableBean().setGoodstable(goodstable);
            }
        }

    }

    @Override
    public void mousePressed(MouseEvent e) {
    }

    @Override
    public void mouseReleased(MouseEvent e) {
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
        List<Goodstable> listrolesuit = AccessSuitMsgUntil.accessIdlEqu(2);
        Goodstable goodstable = null;
        if (this.washJpanel != null) {
            if (this.index + WashJpanel.page * 21 + 1 > listrolesuit.size()) {
                return;
            }

            if (listrolesuit.get(this.index + WashJpanel.page * 21) != null) {
                goodstable = (Goodstable)listrolesuit.get(this.index + WashJpanel.page * 21);
            }
        }

        if (this.upgradeJpanel != null) {
            if (this.index + UpgradeJpanel.page * 21 + 1 > listrolesuit.size()) {
                return;
            }

            if (listrolesuit.get(this.index + UpgradeJpanel.page * 21) != null) {
                goodstable = (Goodstable)listrolesuit.get(this.index + UpgradeJpanel.page * 21);
            }
        }

        if (goodstable != null) {
            ZhuFrame.getZhuJpanel().creatgoodtext(goodstable);
        }

    }

    @Override
    public void mouseExited(MouseEvent e) {
        MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
        ZhuFrame.getZhuJpanel().cleargoodtext();
    }
}
